<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
    <style>
        #all {
            width: 800px;
            height: 100px;
            background-color: #aeefed;
            display: flex;
            justify-content: space-around;
            text-align: center;
            line-height: 100px;
            font-size: 30px;
        }

        #all div {
            width: 200px;
            cursor: pointer;
        }

        .before {
            font-size: 30px;
            background-color: #aeefed;
        }

        .after {
            font-size: 50px;
            background-color: red;
            color: white;
        }
    </style>
</head>

<body>
    <div id="abc">
        <div id="all">
            <div @click="change($event, 0)" :class="classname[0]">首页</div>
            <div @click="change($event, 1)" :class="classname[1]">体育</div>
            <div @click="change($event, 2)" :class="classname[2]">军事</div>
            <div @click="change($event, 3)" :class="classname[3]">生活</div>
        </div>
        <div>
            {{ text }}
        </div>
    </div>
    <script>
        new Vue({
            el: "#abc",
            data: {
                text: "首页",
                classname: ["before", "before", "before", "before"]
            },
            methods: {
                change(event, e) {
                    // console.log(this);
                    this.classname = this.classname.map((val, index) => (index === e ? "after" : "before"));
                    this.text = event.target.textContent;
                }
            }
        })
    </script>
</body>

</html>